import axios from 'poros/http';

// const BASE_API = 'http://10.110.96.192:8030';
const BASE_API = '';

//选择商机列表分页查询
export const postOpportunityList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/opportunity/listByPage`,
    method: 'post',
    data,
  });

//新增订单
export const postAddOrder = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/insert`,
    method: 'post',
    data,
  });

//修改订单
export const postUpdataOrder = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/update`,
    method: 'post',
    data,
  });

//法人下列表分页查询
export const getLegalNoList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/legal/listByPage`,
    method: 'post',
    data,
  });

//获取订单列表
export const postOrderList = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/listByPage`,
    method: 'post',
    data,
  });

//获取订单详情
export const getOrderInfo = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/query/${id}`,
    method: 'get',
  });

//导出模板
export const postDownExcel = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/downExcelImportTemplate`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

//导出订单列表
export const postDownOrderlist = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/listExportTemplate`,
    method: 'post',
    responseType: 'arraybuffer',
    hasInterceptors: true,
    data,
  });

// //批量导入
// export const postUpExcel = data =>
//   axios({
//     url: `${BASE_API}/api/salesforecast-service/order/importExcel`,
//     method: 'post',
//     data,
//   });

//批量导入
export const postUpExcel = file => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/order/importExcel`,
    headers: { 'Content-Type': 'nultipart/form-data' },
    method: 'post',
    data: formData,
  });
};

//删除订单
export const getDeleteOrder = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/order/delete`,
    method: 'post',
    data,
  });

//上传附件
// export const postUpAttachment = data =>
//   axios({
//     url: `${BASE_API}/api/salesforecast-service/attachment/upload/${data}/1`,
//     method: 'post',
//   });

//上传附件
export const postUpAttachment = (file, type) => {
  const formData = new FormData();
  formData.append('file', file);
  return axios({
    url: `${BASE_API}/api/salesforecast-service/attachment/upload/${type}/${type}`,
    headers: { 'Content-Type': 'nultipart/form-data' },
    method: 'post',
    data: formData,
  });
};

//批量删除附件
export const getDeleteFile = id =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/attachment/delete/${id}`,
    method: 'get',
  });

//批量删除附件
export const postDeleteFile = data =>
  axios({
    url: `${BASE_API}/api/salesforecast-service/attachment/delete`,
    method: 'post',
    data,
  });
